﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model.Po;
using nERP.Model.Wms;

namespace nERP.Model.Bas
{
    /// <summary>
    /// 仓库
    /// </summary>
	[Table("Warehouse")]
    [SoftKey(nameof(Warehouse.WarehouseCode))]
    [Display(Name = "_Model.Warehouse")]
    public class Warehouse : BasePoco,IPersistPoco,ITenant
    {
        [Display(Name = "_Model._Warehouse._WarehouseCode")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("仓库编码")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string WarehouseCode { get; set; }
        [Display(Name = "_Model._Warehouse._WarehouseName")]
        [StringLength(64, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("仓库名称")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string WarehouseName { get; set; }
        [Display(Name = "_Model._Warehouse._Address")]
        [StringLength(256, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("地址")]
        public string Address { get; set; }
        [Display(Name = "_Model._Warehouse._StorageFee")]
        [Comment("仓储费(元/天)")]
        public decimal? StorageFee { get; set; }
        [Display(Name = "_Model._Warehouse._ChargePerson")]
        [Comment("负责人")]
        [NotMapped]
        public FrameworkUser ChargePerson { get; set; }
        [Display(Name = "_Model._Warehouse._ChargePerson")]
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("负责人")]
        public string ChargePersonId { get; set; }
        [Display(Name = "_Model._Warehouse._Remark")]
        [StringLength(256, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._BuyDetail._Warehouse")]
        [InverseProperty("Warehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Po.BuyDetail.WarehouseId))]
        public List<BuyDetail> BuyDetail_Warehouse { get; set; }
        [Display(Name = "_Model._BuyInWarehouseDetail._Warehouse")]
        [InverseProperty("Warehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.BuyInWarehouseDetail.WarehouseId))]
        public List<BuyInWarehouseDetail> BuyInWarehouseDetail_Warehouse { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouseDetail._Warehouse")]
        [InverseProperty("Warehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.BuyReturnOutWarehouseDetail.WarehouseId))]
        public List<BuyReturnOutWarehouseDetail> BuyReturnOutWarehouseDetail_Warehouse { get; set; }
        [Display(Name = "_Model._SaleOutWarehouseDetail._Warehouse")]
        [InverseProperty("Warehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.SaleOutWarehouseDetail.WarehouseId))]
        public List<SaleOutWarehouseDetail> SaleOutWarehouseDetail_Warehouse { get; set; }
        [Display(Name = "_Model._SaleReturnInWarehouseDetail._Warehouse")]
        [InverseProperty("Warehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.SaleReturnInWarehouseDetail.WarehouseId))]
        public List<SaleReturnInWarehouseDetail> SaleReturnInWarehouseDetail_Warehouse { get; set; }
        [Display(Name = "_Model._OtherInWarehouseDetail._Warehouse")]
        [InverseProperty("Warehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.OtherInWarehouseDetail.WarehouseId))]
        public List<OtherInWarehouseDetail> OtherInWarehouseDetail_Warehouse { get; set; }
        [Display(Name = "_Model._OtherOutWarehouseDetail._Warehouse")]
        [InverseProperty("Warehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.OtherOutWarehouseDetail.WarehouseId))]
        public List<OtherOutWarehouseDetail> OtherOutWarehouseDetail_Warehouse { get; set; }
        [Display(Name = "_Model._Warehouse._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
